package collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 *新循环
 */
public class NewForDemo {
    public static void main(String[] args) {
       String []a={"one","two","three","four"};
       for(int i=0;i<a.length;i++){
           System.out.println(a[i]);
       }


       for(String str:a){//str表示数组中的每个元素
           System.out.println(str);
       }


        Collection c=new ArrayList();
       c.add("one");
        c.add("two");
        c.add("three");
        c.add("for");
        c.add("five");
        c.add("six");
        Iterator it=c.iterator();
        while(it.hasNext()){
          String s=(String)  it.next();
            System.out.println(s);
        }
        for(Object obj:c){
            String  str=(String) obj;
            System.out.println(str);
        }
        Collection<String>cc=new ArrayList();
        cc.add("ii");
    }
}
